#include <iostream>
#include <string>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>


using namespace std;


pair<long double, int> get(string s)
{
	if (s.length() <= 5)
	{
		if (s[0] == 'n')
			return make_pair(0, 1);
		else
			return make_pair(1, 1);
	} else {
		if (s[0] == 'n')
		{
			pair<long double, int> t = get(s.substr(5));
			long double a = t.first;
			int n = t.second;
		
			return make_pair(a - ((long double)1 / (long double)(1 << n)), n + 1);
		} else {
			pair<long double, int> t = get(s.substr(4));
			long double a = t.first;
			int n = t.second;
	
			return make_pair(a + ((long double)1 / (long double)(1 << n)), n + 1); 
		}
	}
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	string s;
	
	while ( cin >> s)
	{
		if (s == "#")
			break;
		long double ans = get(s).first * 90;
		if (round(ans) == ans)
		{
			cout << round(ans) << endl;
		} else {
			int n = 0;
			while (round(ans) != ans) {
				ans *= 2;
				n++;
			}
			cout << round(ans) << "/" << (1 << n) << endl;
		}
	}
	
	return 0;
}